﻿using BLL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Loginter.运力查询
{
    public partial class SelectCarriers : System.Web.UI.Page
    {
        CarrierBLL carbll = new CarrierBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindCarriesSelect();
            }
        }

        private void BindCarriesSelect()
        {
            #region 查询条件
            string carriesnumber =txt_carriesnumber.Text.Trim();//承运单号
            //承运日期（开始）
            DateTime? leavedate_in = null;
            if (!string.IsNullOrWhiteSpace(txt_carriestime.Text.Trim()))
            {
                leavedate_in = Convert.ToDateTime(txt_carriestime.Text);
            }
            //承运日期（结束）
            DateTime? leavedate_end = null;
            if (!string.IsNullOrWhiteSpace(txt_carrieszhi.Text.Trim()))
            {
                leavedate_end = Convert.ToDateTime(txt_carrieszhi.Text);
            }
            //收货人
            string shouhuo = txt_shuohouren.Text.Trim();
            //收货日期（开始）
            DateTime? time_in = null;
            if (!string.IsNullOrWhiteSpace(txt_shuohuotime.Text.Trim()))
            {
                time_in = Convert.ToDateTime(txt_shuohuotime.Text);
            }
            //收货日期（结束）
            DateTime? time_end = null;
            if (!string.IsNullOrWhiteSpace(txt_shouhuozhi.Text.Trim()))
            {
                time_end = Convert.ToDateTime(txt_shouhuozhi.Text);
            }
            //发货人
            string fahuo = txt_fahuo.Text.Trim();
            //业务人员
            string name = txt_pelper.Text.Trim();
            #endregion
            CarrierMODEL carrier = new CarrierMODEL()
            {
                //CarriersID=Convert.ToInt32(carriesnumber),
                LeaverDate_in = leavedate_in,
                LeaverDate_end = leavedate_end,
                ReceiveLinkman =shouhuo,
                ReceiveDate_in = time_in,
                ReceiveDate_end = time_end,
                SendLinkman =fahuo,
                UserName=name
            };
            List<CarrierinfoMODEL> list = carbll.Get_carrierinfo(carrier);
            grid_select.DataSource = list;
            grid_select.DataBind();
        }

        /// <summary>
        /// 查询按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_select_Click(object sender, EventArgs e)
        {
            BindCarriesSelect();
        }
    }
}